/**
 * Copyright (C) 2018-2020
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package co.yixiang.modules.common.rest;

import co.yixiang.api.ApiResult;
import co.yixiang.modules.commom.domain.YxProtocol;
import co.yixiang.modules.commom.service.YxProtocolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api(value = "协议", tags = "公共:协议", description = "协议")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YxProtocolController {

    private final YxProtocolService yxProtocolService;

    /**
     * 根据type查询协议
     */
    @GetMapping("/findProtocolByType/{type}")
    @ApiOperation(value = "根据type查询协议",notes = "根据type查询协议")
    public ApiResult<YxProtocol> findProtocolByType(@PathVariable Integer type){
        return ApiResult.ok(yxProtocolService.findProtocolByType(type));
    }


    /**
     * 根据type查询协议
     */
    @GetMapping("/findProtocolByDetail/{type}")
    @ApiOperation(value = "根据type查询协议",notes = "根据type查询协议")
    public String findProtocolByDetail(@PathVariable Integer type){
        return yxProtocolService.findProtocolByType(type).getProtocolContent();
    }


}

